package com.xidian.zhiancloud.service.myyb;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.SysJobMapper;
import com.xidian.zhiancloud.dao.SysJobMapperExt;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.SysJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 职位管理
 */
@Service
public class IJobService extends ServiceImpl
        <SysJobMapper, SysJob> implements IService<SysJob>{

    @Autowired
    private SysJobMapperExt jobMapperExt;


    @Autowired
    private SysJobMapper jobMapper;


    public int deleteByPrimaryKey(Long id) {
        return jobMapper.deleteByPrimaryKey(id);
    }

    public int insert(SysJob record) {
        return jobMapperExt.insert(record);
    }

    public int insertSelective(SysJob record) {
        return jobMapperExt.insertSelective(record);
    }

    public SysJob selectByPrimaryKey(Long id) {
        return jobMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(SysJob record) {
        return jobMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(SysJob record) {
        return jobMapperExt.updateByPrimaryKey(record);
    }

    public List<SysJob> selectJobList(Map mapResult) {
        return jobMapperExt.selectJobList(mapResult);
    }

    public SysJob selectByPostName(String postname){
        return jobMapperExt.selectByPostName(postname);
    }

    public List<SysJob> queryList(Map<String, Object> map) {
        return jobMapper.queryList(map);
    }

    public int queryTotal(Map<String, Object> map) {
        return jobMapper.queryTotal(map);
    }

    public void deleteByIds(Long[] ids) {
        for (int i = 0; i < ids.length; i++) {
            int result = jobMapperExt.deleteByIds(ids[i]);
            if (result == 0) {
                throw new CustomizeException(GeneralResponseEnums.SYSTEM_ERROR);
            }
        }
    }

}
